refactor: simplify composite-action report/format helpers#118
Merged
Conversation
Quality cleanups from a 4-angle review of the composite-action diff: - report-common.mjs: add buildReportContext(context); both report wrappers (format-report, jscpd-report) now call it instead of hand-building the identical owner/repo/sha/cwd/runId/commit object. - jscpd-report.mjs: buildJscpdMessage takes the pre-computed `header` (like generateReport) instead of recomputing getReportHeader internally; wrapper passes it. - format-args.mjs: collapse buildDefaultOptions' 4 near-identical blocks to a base + spread (only the two real overrides remain); simplify checkIsDryRun's granular check via a `dry()` helper; drop the unused `config` field from planFormat's return; make internal-only buildArgs/FormatType module-private. - comment.mjs: run the independent listComments + getAuthenticated calls with Promise.all (getAuthenticated still degrades to undefined on 403). - action.yml: write the push stderr log to $RUNNER_TEMP instead of the repo tree, and drop the duplicate ::error:: annotation on exec failure (per-command one remains). Skipped (documented as follow-ups): unifying the jscpd config resolution that happens in both the shell runner and the JS threshold read (structural; risky without an e2e run), and the github-script import boilerplate (explicit per-step is clearer). biome check + 33 node:test green; wrappers smoke-tested; bash -n + YAML clean. Claude-Session: https://claude.ai/code/session_01JxEe85CyGm5rCeoLFdUZed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Quality cleanups on top of the composite-action migration (#117), from a 4-angle
/simplifyreview (reuse, simplification, efficiency, altitude). No behavior change —biome check+ the 33node:testunit tests pass, the github-script wrappers were smoke-tested, andbash -n+ YAML parse are clean.Changes
report-common.mjsgainsbuildReportContext(context); both report wrappers (format-report,jscpd-report) call it instead of hand-building the identicalowner/repo/sha/cwd/runId/commitobject.buildJscpdMessagenow takes the pre-computedheader(likegenerateReport) instead of recomputinggetReportHeaderinternally; the wrapper passes it (removes a double call).buildDefaultOptionscollapses its 4 near-identical blocks to abase+ spread (only the two real overrides remain);checkIsDryRun's granular check uses a smalldry()helper ((enabled && verify) || !enabled→!enabled || verify);planFormatdrops the unusedconfigfield from its return; internal-onlybuildArgs/FormatTypeare now module-private.getExistingCommentIdruns the independentlistComments+getAuthenticatedcalls withPromise.all(the latter still degrades toundefinedon a 403).$RUNNER_TEMPinstead of the repo working tree, and the duplicate::error::annotation on an exec failure is dropped (the per-command annotation remains).Deliberately skipped (documented follow-ups)
--configfile) and the JS threshold read (resolveConfig). They can diverge for a non-defaultjscpdConfigPathcontaining a subdirectory. The deep fix is to resolve jscpd config once in JS and emit a plan (mirroring thedotnet formatpath) — a structural change that's risky to land without a live end-to-end run, so it's left as a follow-up.pathToFileURL/import()boilerplate repeated across 3 steps — explicit per-step imports are clearer than a dispatcher indirection.https://claude.ai/code/session_01JxEe85CyGm5rCeoLFdUZed